home *** CD-ROM | disk | FTP | other *** search
/ MacSilverWare / macsilverware.iso / Screen Savers / DarkSide 4.0 / FaderShell / Invert.c < prev    next >
Text File  |  1993-06-01  |  3KB  |  134 lines

  1. /*
  2.     DarkSide 3.0 - a 7.0 dependant, system clean expandable screen saver.
  3.     
  4.     copyright © 1990, 1991, 1992 by Tom Dowdy
  5.     All rights reserved.
  6.  
  7.     This is a simple fader that shows how to create a fader for DarkSide.
  8. */
  9. #include <Memory.h>
  10. #include <Windows.h>
  11. #include <Dialogs.h>
  12. #include <Errors.h>
  13.  
  14. #include "Fader.h"
  15.  
  16. /* ------------------------------------------------------------------------    */
  17. /* GLOBAL VARIABLES */
  18. /* ------------------------------------------------------------------------    */
  19. long        gNextInvert;            // next time to invert the screens
  20.  
  21. /* ------------------------------------------------------------------------    */
  22. OSErr    PreflightFader(MachineInfoPtr, long *minTicks, long *maxTicks)
  23. /*
  24.     Called when fader is starting up - before window has been created
  25. */
  26. {
  27.     
  28.     // no need to go faster than this!
  29.     *minTicks = 1;
  30.     *maxTicks = 15;
  31.     
  32.     return(noErr);
  33.     
  34. } // PreflightFader
  35.  
  36. /* ------------------------------------------------------------------------    */
  37. OSErr    InitializeFader(MachineInfoPtr machineInfo)
  38. /*
  39.     Called when fader is starting up - after window has been created
  40. */
  41. {
  42.     short            screenIndex;
  43.     ScreenInfoPtr    pScreen;
  44.     
  45.  
  46.     pScreen = &machineInfo->theScreens[0];
  47.     for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  48.         {
  49.         PaintRect(&pScreen->bounds);
  50.             
  51.         ++pScreen;
  52.         }
  53.         
  54.     gNextInvert = TickCount();
  55.     
  56.     return(noErr);
  57.     
  58. } // InitializeFader
  59.  
  60. /* ------------------------------------------------------------------------    */
  61. OSErr    IdleFader(MachineInfoPtr machineInfo)
  62. /*
  63.     Called during idle time for the fader
  64. */
  65. {
  66.     short            screenIndex;
  67.     ScreenInfoPtr    pScreen;
  68.     
  69.  
  70.     if (TickCount() > gNextInvert)
  71.         {
  72.         pScreen = &machineInfo->theScreens[0];
  73.         for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  74.             {
  75.             if (Random() & 0x01)
  76.                 InvertRect(&pScreen->bounds);
  77.                 
  78.             ++pScreen;
  79.             }
  80.  
  81.         gNextInvert = TickCount() 
  82.             + (9-machineInfo->faderSettings->theShorts[0]) * 10;
  83.         }
  84.         
  85.     return(noErr);
  86.     
  87. } // IdleFader
  88.  
  89.  
  90. /* ------------------------------------------------------------------------    */
  91. OSErr    DisposeFader(MachineInfoPtr )
  92. /*
  93.     Called when the fade is tearing down
  94. */
  95. {
  96.     
  97.     return(noErr);
  98.     
  99. } // DisposeFader
  100.  
  101. /* ------------------------------------------------------------------------    */
  102. OSErr    UpdateFader(MachineInfoPtr machineInfo)
  103. /*
  104.     Called when there is an update event for our fade window.
  105. */
  106. {
  107.     // erase the screen
  108.     InitializeFader(machineInfo);
  109.     return(noErr);
  110.     
  111. } // UpdateFader
  112.  
  113. /* ------------------------------------------------------------------------    */
  114. OSErr    HitFader(MachineInfoPtr machineInfo, DialogPtr dPtr, short itemHit, short itemOffset)
  115. /*
  116.     Called when there is an event in the settings dialog.  itemHit will be
  117.     the item the user has selected, or 0 when the dialog is being set up.
  118.     
  119.     itemHit - itemOffset will allow you to determine which item in your dialog
  120.     list this corresponds to.
  121.     
  122.     If you don't wish to do any special processing of this event, simply return
  123.     "fnfErr" and the standard effect will take place.
  124.     
  125.     WARNING: Your A5 world may not be set up at this point, so don't try to use
  126.     your global variables!!!
  127. */
  128. {
  129. #pragma unused (machineInfo, dPtr, itemHit, itemOffset)
  130.  
  131.     return(fnfErr);
  132.     
  133. } // HitFader
  134.